package cn.my.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {
    /*状态码 200 成功  501 失败*/
    private Integer code;
    /*返回的消息*/
    private String  msg;
    /*返回的结果对象*/
    private Object data;

    public static Result  success(Object data){
     return    new Result(200,"操作成功",data);
    }
    public static Result  success(){
        return    new Result(200,"操作成功",null);
    }

    public static Result  fail(){
        return    new Result(501,"操作失败",null);
    }

    public static Result  fail(String msg){
        return    new Result(501,msg,null);
    }
    public static Result  fail(Integer code,String msg){
        return    new Result(code,msg,null);
    }
}
